unit dmsibec_unt;

interface

uses
  Forms, Controls,
  SysUtils, Classes, DB, IBCustomDataSet, IBQuery, IBDatabase;

type
  TDMSIBEC_frm = class(TDataModule)
    IBQTemp: TIBQuery;
    IBQBloco: TIBQuery;
    IBQTempFolha: TIBQuery;
    IBQEstatistica: TIBQuery;
    procedure DataModuleCreate(Sender: TObject);
    procedure DataModuleDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  DMSIBEC_frm: TDMSIBEC_frm;

implementation

{$R *.dfm}

uses DMSistema_unt;

procedure TDMSIBEC_frm.DataModuleCreate(Sender: TObject);
begin
   try
      Screen.Cursor := crSQLWait;
      if DMSistema_frm.IBDataBaseSIGAS.Connected then DMSistema_frm.IBDataBaseSIGAS.Connected := False;
      with DMSistema_frm.IBDataBaseSIGAS do
      begin
         try
            Connected := True;
         except
         end;
      end;
   finally
      Screen.Cursor := crDefault;
   end;
end;

procedure TDMSIBEC_frm.DataModuleDestroy(Sender: TObject);
begin
   try
      Screen.Cursor := crSQLWait;
      if DMSistema_frm.IBTransactionSIGAS.InTransaction then DMSistema_frm.IBTransactionSIGAS.RollbackRetaining;
      if DMSistema_frm.IBTransactionSIGAS.Active then
      begin
         with DMSistema_frm.IBTransactionSIGAS do
         begin
            try
               Active := False;
            except
            end;
         end;
      end;
      if DMSistema_frm.IBDataBaseSIGAS.Connected then
      begin
         with DMSistema_frm.IBDataBaseSIGAS do
         begin
            try
               Connected := False;
            except
            end;
         end;
      end;
   finally
      Screen.Cursor := crDefault;
   end;
end;

end.
